#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;

int n, m, d;
char a[15][15];
int ans;
int solve(int s, int t) {
  int x1 = (s - 1) / m + 1;
  int y1 = (s - 1) % m + 1;
  int x2 = (t - 1) / m + 1;
  int y2 = (t - 1) % m + 1;
  if (a[x1][y1] == '#') return 0;
  if (a[x2][y2] == '#') return 0;
  int cnt = 0;
  rep(i, 1, n) rep(j, 1, m) {
    if (a[i][j] == '#') continue;
    int d1 = abs(i - x1) + abs(j - y1);
    int d2 = abs(i - x2) + abs(j - y2);
    if (min(d1, d2) <= d) cnt++;
  }
  return cnt;
}
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n >> m >> d;
  rep(i, 1, n) rep(j, 1, m) cin >> a[i][j];
  rep(i, 1, n * m) rep(j, i + 1, n * m) ans = max(ans, solve(i, j));
  cout << ans;
  return 0;
}